﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utility.Events;

namespace TimeTracker.EditForms
{
    public partial class AddNote : Form
    {
        protected ISession session
        {
            get;
            set;
        }

        public AddNote(ISession session)
        {
            this.session = session;

            InitializeComponent();

            this.note1.MinTime = this.session.StartTime;
            if (this.session.EndTime.HasValue)
            {
                this.note1.MaxTime = this.session.EndTime.Value;
            }
            this.note1.Time = this.session.StartTime;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            INote note = Manager.Instance.AddNote(session, this.note1.Time, this.note1.Text);

            Manager.Instance.Save();

            this.Saved.Fire(sender, note);

            this.Close();
        }

        public event EventHandler<EventArgs<INote>> Saved;
    }
}
